package com.jiangruan.javaproject.service;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaproject.Constants;
import com.jiangruan.javaproject.bean.HotVideo;
import com.jiangruan.javaproject.bean.HotVideoCommon;
import com.jiangruan.javaproject.request.HttpUtils;

import java.util.List;

/**
 * @author:张子寒
 * @email:1594426628@qq.com
 * @desc:该方法用于获取热门数据，并将热门数据返回
 * @DateTime:2021-12-04
 **/
public class HotVideoService {
    public List<HotVideo> getHotVideo(){
        String url= Constants.TRIP_URL
                +"?key="+Constants.TRIP_KEY
                +"&type=hot_video"
                +"&size=20";
        String result = HttpUtils.get(url);
        System.out.println(result);
        //json解析
        HotVideoCommon VideoCommon = JSONObject.parseObject(result, HotVideoCommon.class);
//        System.out.println(VideoCommon.reason);
//        System.out.println(VideoCommon.error_code);
//        System.out.println(VideoCommon.result.size());
        return VideoCommon.result;
    }
}
